﻿var app = angular.module('Emergency', []);

app.controller("EmergencyController", function ($scope, $http, $window, $filter, $interval, $compile) {
    $scope.InitEpi = function () {
        var myChart = echarts.init(document.getElementById('chart_epi'));
        var option = {
            series: [{
                type: 'gauge',
                startAngle: 180,
                endAngle: 0,
                radius: '110%',
                min: 0,
                max: 100,
                splitNumber: 10,
                center: ['50%', '75%'],
                axisLine: {
                    lineStyle: {
                        width: 6,
                        color: [
                            [0.6, 'red'],
                            [0.8, 'orange'],
                            [1, 'green']
                        ]
                    }
                },
                pointer: {
                    icon: 'path://M12.8,0.7l12,40.1H0.7L12.8,0.7z',
                    length: '50%',
                    width: 10,
                    offsetCenter: [0, '-40%'],
                    itemStyle: {
                        color: 'auto'
                    }
                },
                axisTick: {
                    length: 12,
                    lineStyle: {
                        color: 'white',
                        width: 2
                    }
                },
                axisLabel: {
                    color: 'white'
                },
                splitLine: {
                    length: 20,
                    lineStyle: {
                        color: 'white',
                        width: 5
                    }
                },

                title: {
                    offsetCenter: [0, '-20%'],
                    fontSize: 30,
                    textStyle: {
                        color: 'white'
                    }
                },
                detail: {
                    fontSize: 30,
                    offsetCenter: [0, '0%'],
                    valueAnimation: true,
                    formatter: function (value) {
                        return value;
                    },
                    color: 'auto'
                },
                data: [{
                    value: 78.56,
                    name: 'EPI'
                }]
            }]
        };

        $scope.EPIScore = {};
        $http({
            method: 'POST',
            url: '../DashBoard/GetEPI',
        })
            .success(function (ret) {
                $scope.EPIScore = ret.value.toFixed(2);
                option.series[0].data[0].value = $scope.EPIScore;
                myChart.setOption(option);
                window.addEventListener("resize", function () {
                    myChart.resize();
                });
            })
            .error(function (data, status, headers, config) {
            });




        setInterval(function () {
            $http({
                method: 'POST',
                url: '../DashBoard/GetEPI',
            })
                .success(function (ret) {
                    $scope.EPIScore = ret.value.toFixed(2);
                    option.series[0].data[0].value = $scope.EPIScore;
                    myChart.setOption(option);
                })
                .error(function (data, status, headers, config) {
                });
        }, 20000);
    }

    $scope.InitSPI = function () {
        var myChart = echarts.init(document.getElementById('chart_safekpi'));
        var option = {
            series: [{
                type: 'gauge',
                startAngle: 180,
                endAngle: 0,
                radius: '110%',
                min: 0,
                max: 100,
                splitNumber: 10,
                center: ['50%', '75%'],
                axisLine: {
                    lineStyle: {
                        width: 6,
                        color: [
                            [0.59, 'red'],
                            [0.79, 'orange'],
                            [1, 'green']
                        ]
                    }
                },
                pointer: {
                    icon: 'path://M12.8,0.7l12,40.1H0.7L12.8,0.7z',
                    length: '50%',
                    width: 10,
                    offsetCenter: [0, '-40%'],
                    itemStyle: {
                        color: 'auto'
                    }
                },
                axisTick: {
                    length: 12,
                    lineStyle: {
                        color: 'white',
                        width: 2
                    }
                },
                splitLine: {
                    length: 20,
                    lineStyle: {
                        color: 'white',
                        width: 5
                    }
                },
                axisLabel: {
                    color: 'white'
                },
                title: {
                    offsetCenter: [0, '-20%'],
                    fontSize: 30,
                    textStyle: {
                        color: 'white'
                    }
                },
                detail: {
                    fontSize: 30,
                    offsetCenter: [0, '0%'],
                    valueAnimation: true,
                    formatter: function (value) {
                        return value;
                    },
                    color: 'auto'
                },
                data: [{
                    value: 80.56,
                    name: 'SPI'
                }]
            }]
        };
        $http({
            method: 'POST',
            url: '../Emergency/GetSPI',
        })
            .success(function (ret) {
                option.series[0].data[0].value = ret.toFixed(2);
                myChart.setOption(option);
                window.addEventListener("resize", function () {
                    myChart.resize();
                });
            })
            .error(function (data, status, headers, config) {
            });
        setInterval(function () {
            $http({
                method: 'POST',
                url: '../Emergency/GetSPI',
            })
                .success(function (ret) {
                    option.series[0].data[0].value = ret.toFixed(2);
                    myChart.setOption(option);
                    window.addEventListener("resize", function () {
                        myChart.resize();
                    });
                })
                .error(function (data, status, headers, config) {
                });
        }, 55000);

    }

    $scope.DangerPlaceKPI = function () {

        var myColor = ['red', 'green', 'green', '#F8B448', '#8B78F6'];

        var histogramChart1 = echarts.init(document.getElementById('chart_dangerplacekpi'));

        var option = {
            title: {
                text: '运行指数',
                left: 'center',
                top: 30,
                textStyle: { color: 'white', fontSize: 14 }
            },
            grid: {
                top: '20%',
                left: '32%'
            },
            xAxis: {
                show: false
            },
            yAxis: [{
                show: true,
                data: ['I级危险点', 'II级危险点', 'III级危险点'],
                inverse: true,
                axisLine: {
                    show: false
                },
                splitLine: {
                    show: false
                },
                axisTick: {
                    show: false
                },
                axisLabel: {

                    color: '#fff',
                    formatter: (value, index) => {
                        return [
                            '{title|' + value + '} '
                        ].join('\n')
                    },
                    rich: {
                        lg: {
                            backgroundColor: '#339911',
                            color: '#fff',
                            borderRadius: 15,
                            // padding: 5,
                            align: 'center',
                            width: 15,
                            height: 15
                        },
                    }
                },


            }, {
                show: false,
                inverse: true,
                data: [77, 100, 100],
                axisLabel: {
                    textStyle: {
                        fontSize: 12,
                        color: '#fff',
                    },
                },
                axisLine: {
                    show: false
                },
                splitLine: {
                    show: false
                },
                axisTick: {
                    show: false
                },

            }],
            series: [{
                name: '条',
                type: 'bar',
                yAxisIndex: 0,
                data: [77, 100, 100],
                barWidth: 10,
                itemStyle: {
                    normal: {
                        barBorderRadius: 20,
                        color: function (params) {
                            var num = myColor.length;
                            return myColor[params.dataIndex % num]
                        },
                    }
                },
                label: {
                    normal: {
                        show: true,
                        position: 'inside',
                        formatter: '{c}'
                    }
                },
            }, {
                name: '框',
                type: 'bar',
                yAxisIndex: 1,
                barGap: '-100%',
                data: [100, 100, 100, 100],
                barWidth: 15,
                itemStyle: {
                    normal: {
                        color: 'none',
                        borderColor: '#00c1de',
                        borderWidth: 3,
                        barBorderRadius: 15,
                    }
                }
            },]
        };
        $http({
            method: 'POST',
            url: '../Emergency/GetDangerPlaceKPI',
        })
            .success(function (ret) {
                var val = ret.toFixed(2);
                if (val >= 100) {
                    val = 98.35;
                }
                if (val > 85) {
                    myColor[0] = "green";
                }
                else if (val > 60 && val < 85) {
                    myColor[0] = "orange";
                }
                else if (val > 60 && val < 85) {
                    myColor[0] = "red";
                }
                option.series[0].data = [val, 100, 100]
                histogramChart1.setOption(option);
            })
            .error(function (data, status, headers, config) {
            });
        setInterval(function () {
            $http({
                method: 'POST',
                url: '../Emergency/GetDangerPlaceKPI',
            })
                .success(function (ret) {
                    var val = ret.toFixed(2);
                    option.series[0].data = [val, 100, 100]
                    histogramChart1.setOption(option);
                })
                .error(function (data, status, headers, config) {
                });
        }, 55000);
    }

    //根据危险点等级渲染饼图
    $scope.InitPieChartByDangerLevel = function () {
        var myChart = echarts.init(document.getElementById('chart_level'));
        var option1 = {
            legend: {
                show: true,
                x: 'left',
                orient: 'vertical',
                y: '15%',
                data: [],
                textStyle: {
                    color: 'white',
                }
            },
            tooltip: {
                trigger: 'item',
                formatter: '等级：{b} <br/> 数量：{c}'
            },
            series: [
                {
                    name: '危险点厂区分布',
                    type: 'pie',
                    radius: ['30%', '50%'],
                    center: ['50%', '50%'],
                    avoidLabelOverlap: true,
                    label: {
                        show: true,
                        formatter: '{b}:{c}',
                        textStyle: {
                            color: 'white'
                        }
                    },
                    emphasis: {
                        label: {
                            show: false,
                            fontSize: '40',
                            fontWeight: 'bold'
                        }
                    },
                    labelLine: {
                        show: true
                    },
                    data: [],
                    itemStyle: {
                        normal: {
                            // 随机显示
                            //color:function(d){return "#"+Math.floor(Math.random()*(256*256*256-1)).toString(16);}

                            // 定制显示（按顺序）
                            color: function (params) {
                                var colorList = ['#63b2ee', '#76da91', '#f8cb7f', '#b6b51f', '#7cd6cf', '#76da91', '#9192ab', '#2F4554', '#C23531', '#749F83', '#749F83', '#E98F6F', '#61A0A8', '#2F4554', '#C23531', '#749F83', '#749F83', '#E98F6F', '#61A0A8', '#2F4554', '#C23531', '#749F83',];
                                return colorList[params.dataIndex]
                            }
                        },
                    }
                }
            ]
        };
        $http({
            method: 'POST',
            url: '../Emergency/GetDangerPlaceChartData',
            data: { 'type': 3 }
        })
            .success(function (ret) {
                var datalist = [];
                var legenddata = [];
                for (var i = 0; i < ret.length; i++) {
                    var obj = {};
                    obj.name = ret[i].DangerousLevel;
                    obj.value = ret[i].CountNum;
                    datalist.push(obj);
                    legenddata.push(ret[i].DangerousLevel);
                }
                option1.legend.data = legenddata;
                option1.series[0].data = datalist;
                myChart.setOption(option1);
            })
            .error(function (data, status, headers, config) {
            });
    }

    //根据厂区渲染饼图
    $scope.InitPieChartByFactory = function () {
        var myChart = echarts.init(document.getElementById('chart_factory'));
        var option1 = {
            legend: {
                show: true,
                x: 'left',
                orient: 'vertical',
                y: '15%',
                data: [],
                textStyle: {
                    color: 'white',
                }
            },
            tooltip: {
                trigger: 'item',
                formatter: '厂区：{b} <br/> 数量：{c}'
            },
            series: [
                {
                    name: '危险点厂区分布',
                    type: 'pie',
                    radius: ['30%', '50%'],
                    center: ['50%', '50%'],
                    avoidLabelOverlap: true,
                    label: {
                        show: true,
                        formatter: '{b}:{c}',
                        textStyle: {
                            color: 'white'
                        }
                    },
                    emphasis: {
                        label: {
                            show: false,
                            fontSize: '40',
                            fontWeight: 'bold'
                        }
                    },
                    labelLine: {
                        show: true
                    },
                    data: [],
                    itemStyle: {
                        normal: {
                            // 随机显示
                            //color:function(d){return "#"+Math.floor(Math.random()*(256*256*256-1)).toString(16);}

                            // 定制显示（按顺序）
                            color: function (params) {
                                var colorList = ['#63b2ee', '#76da91', '#f8cb7f', '#b6b51f', '#7cd6cf', '#76da91', '#9192ab', '#2F4554', '#C23531', '#749F83', '#749F83', '#E98F6F', '#61A0A8', '#2F4554', '#C23531', '#749F83', '#749F83', '#E98F6F', '#61A0A8', '#2F4554', '#C23531', '#749F83',];
                                return colorList[params.dataIndex]
                            }
                        },
                    }
                }
            ]
        };
        $http({
            method: 'POST',
            url: '../Emergency/GetDangerPlaceChartData',
            data: { 'type': 1 }
        })
            .success(function (ret) {
                var datalist = [];
                var lengendlist = [];
                for (var i = 0; i < ret.length; i++) {
                    var obj = {};
                    obj.name = ret[i].AreaName;
                    obj.value = ret[i].CountNum;
                    datalist.push(obj);
                    lengendlist.push(ret[i].AreaName);
                }
                option1.legend.data = lengendlist;
                option1.series[0].data = datalist;
                myChart.setOption(option1);
            })
            .error(function (data, status, headers, config) {
            });
    }

    //根据部门渲染饼图
    $scope.InitPieChartByDepartment = function () {
        var myChart = echarts.init(document.getElementById('chart_department'));
        var option1 = {
            legend: {
                show: false,
                x: 'center',
                y: '15%',
                data: [],
                icon: 'circle',
                textStyle: {
                    color: 'white',
                }
            },
            tooltip: {
                trigger: 'item',
                formatter: '厂区：{b} <br/> 数量：{c}'
            },
            series: [
                {
                    name: '危险点厂区分布',
                    type: 'pie',
                    radius: ['30%', '50%'],
                    center: ['50%', '55%'],
                    avoidLabelOverlap: true,
                    label: {
                        show: true,
                        formatter: '{b}:{c}',
                        textStyle: {
                            color: 'white'
                        }
                    },
                    emphasis: {
                        label: {
                            show: false,
                            fontSize: '40',
                            fontWeight: 'bold'
                        }
                    },
                    labelLine: {
                        show: true
                    },
                    data: [],
                    itemStyle: {
                        normal: {
                            // 随机显示
                            //color:function(d){return "#"+Math.floor(Math.random()*(256*256*256-1)).toString(16);}

                            // 定制显示（按顺序）
                            color: function (params) {
                                var colorList = ['#63b2ee', '#76da91', '#f8cb7f', '#b6b51f', '#7cd6cf', '#76da91', '#9192ab', '#2F4554', '#9370DB', '#749F83', '#749F83', '#E98F6F', '#61A0A8', '#2F4554', '#C23531', '#749F83', '#749F83', '#E98F6F', '#61A0A8', '#2F4554', '#FFE4B5', '#749F83',];
                                return colorList[params.dataIndex]
                            }
                        },
                    }
                }
            ]
        };
        $http({
            method: 'POST',
            url: '../Emergency/GetDangerPlaceChartData',
            data: { 'type': 2 }
        })
            .success(function (ret) {
                var datalist = [];
                for (var i = 0; i < ret.length; i++) {
                    var obj = {};
                    obj.name = ret[i].Department;
                    obj.value = ret[i].CountNum;
                    datalist.push(obj);
                }
                option1.series[0].data = datalist;
                myChart.setOption(option1);
            })
            .error(function (data, status, headers, config) {
            });
    }

    //
    $scope.InitPieChartBySpecialItem = function () {
        var myChart = echarts.init(document.getElementById('chart_specialitem'));
        var option1 = {
            grid: {
                left: '1%',
                right: '1%',
                bottom: '1%',
                containLabel: true
            },
            legend: {
                show: false,
                x: 'center',
                y: '15%',
                data: [],
                icon: 'circle',
                textStyle: {
                    color: 'white',
                }
            },
            tooltip: {
                trigger: 'item',
                formatter: '持证类别：{b} <br/> 数量：{c}'
            },
            series: [
                {
                    name: '危险点设备持证分布',
                    type: 'pie',
                    radius: ['30%', '50%'],
                    center: ['50%', '55%'],
                    avoidLabelOverlap: true,
                    label: {
                        show: true,
                        formatter: '{b}:{c}',
                        textStyle: {
                            color: 'white'
                        }
                    },
                    emphasis: {
                        label: {
                            show: false,
                            fontSize: '40',
                            fontWeight: 'bold'
                        }
                    },
                    labelLine: {
                        show: true
                    },
                    data: [],
                    itemStyle: {
                        normal: {
                            // 随机显示
                            //color:function(d){return "#"+Math.floor(Math.random()*(256*256*256-1)).toString(16);}

                            // 定制显示（按顺序）
                            color: function (params) {
                                var colorList = ['#63b2ee', '#76da91', '#f8cb7f', '#b6b51f', '#7cd6cf', '#76da91', '#9192ab', '#2F4554', '#9370DB', '#749F83', '#749F83', '#E98F6F', '#61A0A8', '#2F4554', '#C23531', '#749F83', '#749F83', '#E98F6F', '#61A0A8', '#2F4554', '#FFE4B5', '#749F83',];
                                return colorList[params.dataIndex]
                            }
                        },
                    }
                }
            ]
        };
        $http({
            method: 'POST',
            url: '../Emergency/GetDangerPlaceOperate'
        })
            .success(function (ret) {
                var datalist = [];
                for (var i = 0; i < ret.length; i++) {
                    var obj = {};
                    obj.name = ret[i].Type;
                    obj.value = ret[i].CountNum;
                    datalist.push(obj);
                }
                option1.series[0].data = datalist;
                myChart.setOption(option1);
            })
            .error(function (data, status, headers, config) {
            });
    }
    //SSOP
    $scope.InitSSOPChart = function () {
        var myChart = echarts.init(document.getElementById('chart_sop'));
        var option = {
            grid: {
                left: '1%',
                right: '1%',
                bottom: '1%',
                containLabel: true
            },
            xAxis: {
                type: 'category',
                data: ['2020-11', '2020-12', '2021-01', '2021-02', '2021-03', '2021-04', '2021-05'],
                axisLine: {
                    lineStyle: {
                        color: 'white',
                        width: 1, //这里是为了突出显示加上的  
                    }
                },

            },
            yAxis: {
                type: 'value',
                splitLine: { show: false },
                axisLine: {
                    lineStyle: {
                        color: 'white',
                        width: 1, //这里是为了突出显示加上的  
                    }
                }
            },
            series: [{
                data: [120, 200, 150, 80, 70, 110, 130],
                type: 'bar',
                showBackground: false,
                backgroundStyle: {
                    color: 'rgba(180, 180, 180, 0.2)'
                }
            }]
        };
        myChart.setOption(option);
    }

    $scope.Init2014SPI = function () {
        var myChart = echarts.init(document.getElementById('chart_spi'));
        var option = {
            series: [{
                type: 'gauge',
                startAngle: 180,
                endAngle: 0,
                radius: '110%',
                min: 0,
                max: 100,
                splitNumber: 10,
                center: ['50%', '75%'],
                axisLine: {
                    lineStyle: {
                        width: 6,
                        color: [
                            [0.59, 'red'],
                            [0.79, 'orange'],
                            [1, 'green']
                        ]
                    }
                },
                pointer: {
                    icon: 'path://M12.8,0.7l12,40.1H0.7L12.8,0.7z',
                    length: '50%',
                    width: 10,
                    offsetCenter: [0, '-40%'],
                    itemStyle: {
                        color: 'auto'
                    }
                },
                axisTick: {
                    length: 12,
                    lineStyle: {
                        color: 'white',
                        width: 2
                    }
                },
                splitLine: {
                    length: 20,
                    lineStyle: {
                        color: 'white',
                        width: 5
                    }
                },
                axisLabel: {
                    color: 'white'
                },
                title: {
                    offsetCenter: [0, '-20%'],
                    fontSize: 30,
                    textStyle: {
                        color: 'white'
                    }
                },
                detail: {
                    fontSize: 30,
                    offsetCenter: [0, '0%'],
                    valueAnimation: true,
                    formatter: function (value) {
                        return value;
                    },
                    color: 'auto'
                },
                data: [{
                    value: 80.56,
                    name: 'SPI'
                }]
            }]
        };
        $http({
            method: 'POST',
            url: '../Emergency/GetDangerPlaceKPI',
        })
            .success(function (ret) {
                option.series[0].data[0].value = ret.toFixed(2);
                myChart.setOption(option);
                window.addEventListener("resize", function () {
                    myChart.resize();
                });
            })
            .error(function (data, status, headers, config) {
            });
        setInterval(function () {
            $http({
                method: 'POST',
                url: '../Emergency/GetDangerPlaceKPI',
            })
                .success(function (ret) {
                    option.series[0].data[0].value = ret.toFixed(2);
                    myChart.setOption(option);
                    window.addEventListener("resize", function () {
                        myChart.resize();
                    });
                })
                .error(function (data, status, headers, config) {
                });
        }, 55000);

    }

    $scope.GetTodayAlarmTimes = function () {
        $scope.AlarmTimes = 0;
        $http({
            method: 'POST',
            url: '../Emergency/GetTodayAlarmTimes',
        })
            .success(function (ret) {
                $scope.AlarmTimes = ret;
            })
            .error(function (data, status, headers, config) {
            });
        setInterval(function () {
            $http({
                method: 'POST',
                url: '../Emergency/GetTodayAlarmTimes',
            })
                .success(function (ret) {
                    $scope.AlarmTimes = ret;
                })
                .error(function (data, status, headers, config) {
                });
        }, 60000);
    };
    $scope.GetExhaust = function () {
        var Type = "非甲烷总烃";
        var yname = "mg/m³";
        var charobj = document.getElementById('chart_exhaust');
        charobj.style.width = (document.getElementById('chart_exhaust')).offsetWidth + "px";
        var myChart = echarts.init(charobj);
        var valuelist = [];
        var timelist = [];
        var namelist = [];
        var option = {};
        var colorarrays = ["#00FFFF", "#00FA9A", "#4169E1", "#006400", "#5F9EA0", "#4682B4", "white", "#357F88", "#673509", "#310937", "#1B9637", "#F7393C"];
        var minvalue = 0;
        var maxvalue = 0;

        $http({
            method: 'POST',
            url: '../Dashboard/GetHistoryData?Config=' + Type
        })
            .success(function (datas) {
                for (var i = 0; i < datas.length; i++) {
                    namelist.push(datas[i].Name);
                    timelist = datas[i].TimeStr;
                }
                if (datas.length > 0) {
                    minvalue = datas[0].Min;
                    maxvalue = datas[0].Max + 10;
                }
                option = {
                    legend: {
                        data: namelist,
                        left: 'right',
                        top: 20,
                        textStyle: {
                            color: "#fff"
                        },
                    },
                    tooltip: {
                        trigger: 'axis'
                    },
                    xAxis: [
                        {
                            type: 'category',
                            boundaryGap: false,
                            data: timelist,
                            axisLine: {
                                show: true,
                                lineStyle: {
                                    color: "rgba(219,225,255,1)",
                                    width: 1,
                                    type: "solid"
                                }
                            },
                            splitLine: {
                                show: true,
                                lineStyle: {
                                    color: ['#2F4F4F'],
                                    width: 1,
                                    type: 'solid'
                                }
                            }


                        }
                    ],
                    yAxis: [
                        {
                            min: minvalue,
                            // min 是最小的值
                            max: maxvalue,
                            splitLine: {
                                show: true,
                                lineStyle: {
                                    color: ['#2F4F4F'],
                                    width: 1,
                                    type: 'solid'
                                }
                            },
                            type: 'value',
                            name: 'mg/m3',
                            axisLine: {
                                show: true,
                                lineStyle: {
                                    color: "rgba(219,225,255,1)",
                                    width: 1,
                                    type: "solid"
                                }
                            }
                        }
                    ],
                    series: []
                };
                option.series = [];

                for (var i = 0; i < namelist.length; i++) {
                    var obj = {
                        name: namelist[i],
                        data: datas[i].Values,
                        type: 'line',
                        smooth: true,
                        itemStyle: {
                            normal: {
                                color: colorarrays[i],
                                lineStyle: {
                                    color: colorarrays[i],
                                }
                            }
                        },
                        markLine: {
                            silent: true,
                            symbol: "none",
                            lineStyle: {
                                color: '#333'
                            },
                            data: [
                                {
                                    yAxis: 50,
                                    color: 'white',
                                    lineStyle: {               //警戒线的样式  ，虚实  颜色
                                        type: "dashed",
                                        color: "yellow"
                                    },
                                    label: {
                                        show: true,
                                        color: 'white'
                                    }

                                },
                                {
                                    yAxis: 60,
                                    lineStyle: {               //警戒线的样式  ，虚实  颜色
                                        type: "dashed",
                                        color: "orange"
                                    },
                                    label: {
                                        show: true,
                                        color: 'white'
                                    }
                                },
                                {
                                    yAxis: 70,
                                    lineStyle: {               //警戒线的样式  ，虚实  颜色
                                        type: "dashed",
                                        color: "red"
                                    },
                                    label: {
                                        show: true,
                                        color: 'white'
                                    }

                                }
                            ]
                        }
                    };
                    option.series.push(obj);
                }

                myChart.setOption(option, true);
                myChart.resize();
            })
            .error(function (data, status, headers, config) {
            });

        times = setInterval(function () {
            $.ajax({
                type: "post",
                url: '../Dashboard/GetNowData?Config=' + Type,
                success: function (datas) {
                    if (datas.length > 0) {
                        option.xAxis[0].data.shift();
                        option.xAxis[0].data.push(datas[0].TimeStr);
                    }
                    for (var i = 0; i < datas.length; i++) {
                        var name = datas[i].Name;
                        for (var j = 0; j < option.series.length; j++) {
                            if (option.series[j].name == name) {
                                option.series[j].data.shift();
                                option.series[j].data.push(datas[i].Values);
                                if (datas[i].Values < minvalue || datas[i].Values > maxvalue) {
                                    option.series[j].itemStyle.normal.lineStyle.color = "red";
                                    option.series[j].itemStyle.normal.color = "red";
                                }
                                else {
                                    option.series[j].itemStyle.normal.lineStyle.color = colorarrays[j];
                                    option.series[j].itemStyle.normal.color = colorarrays[j];
                                }
                            }
                        }
                    }
                    myChart.setOption(option);

                }, error: function (err) {

                }
            });
        }, 60000);

    }
    $scope.GetGLFExhaust = function () {
        var Type = "氮氧化合物";
        var yname = "mg/m³";
        var charobj = document.getElementById('chart_exhaust');
        charobj.style.width = (document.getElementById('chart_exhaust')).offsetWidth + "px";
        var myChart = echarts.init(charobj);
        var valuelist = [];
        var timelist = [];
        var namelist = [];
        var option = {};
        var colorarrays = ["#00FFFF", "#00FA9A", "#4169E1", "#006400", "#5F9EA0", "#4682B4", "white", "#357F88", "#673509", "#310937", "#1B9637", "#F7393C"];
        var minvalue = 0;
        var maxvalue = 0;
        var mnlist = ['env_realtime#100000000031011512150782'];
        $http({
            method: 'POST',
            url: '../Dashboard/GetHistoryDataByMn',
            data: { "Config": Type, "Env_MnNoList": mnlist }
        })
            .success(function (datas) {
                for (var i = 0; i < datas.length; i++) {
                    namelist.push(datas[i].Name);
                    timelist = datas[i].TimeStr;
                }
                if (datas.length > 0) {
                    minvalue = datas[0].Min;
                    maxvalue = 300;//datas[0].Max;
                }
                option = {
                    legend: {
                        data: namelist,
                        left: 'right',
                        top: 20,
                        textStyle: {
                            color: "#fff"
                        },
                    },
                    tooltip: {
                        trigger: 'axis'
                    },
                    xAxis: [
                        {
                            type: 'category',
                            boundaryGap: false,
                            data: timelist,
                            axisLine: {
                                show: true,
                                lineStyle: {
                                    color: "rgba(219,225,255,1)",
                                    width: 1,
                                    type: "solid"
                                }
                            },
                            splitLine: {
                                show: true,
                                lineStyle: {
                                    color: ['#2F4F4F'],
                                    width: 1,
                                    type: 'solid'
                                }
                            }


                        }
                    ],
                    yAxis: [
                        {
                            min: minvalue,
                            // min 是最小的值
                            max: 300,
                            splitLine: {
                                show: true,
                                lineStyle: {
                                    color: ['#2F4F4F'],
                                    width: 1,
                                    type: 'solid'
                                }
                            },
                            type: 'value',
                            name: 'mg/m3',
                            axisLine: {
                                show: true,
                                lineStyle: {
                                    color: "rgba(219,225,255,1)",
                                    width: 1,
                                    type: "solid"
                                }
                            }
                        }
                    ],
                    series: []
                };
                option.series = [];

                for (var i = 0; i < namelist.length; i++) {
                    var obj = {
                        name: namelist[i],
                        data: datas[i].Values,
                        type: 'line',
                        smooth: true,
                        itemStyle: {
                            normal: {
                                color: colorarrays[i],
                                lineStyle: {
                                    color: colorarrays[i],
                                }
                            }
                        },
                        markLine: {
                            silent: true,
                            symbol: "none",
                            lineStyle: {
                                color: '#333'
                            },
                            data: [
                                //{
                                //    yAxis: 30,
                                //    color: 'white',
                                //    lineStyle: {               //警戒线的样式  ，虚实  颜色
                                //        type: "dashed",
                                //        color: "yellow"
                                //    },
                                //    label: {
                                //        show: true,
                                //        color: 'white'
                                //    }

                                //},
                                //{
                                //    yAxis: 40,
                                //    lineStyle: {               //警戒线的样式  ，虚实  颜色
                                //        type: "dashed",
                                //        color: "orange"
                                //    },
                                //    label: {
                                //        show: true,
                                //        color: 'white'
                                //    }
                                //},
                                {
                                    yAxis: 50,
                                    lineStyle: {               //警戒线的样式  ，虚实  颜色
                                        type: "dashed",
                                        color: "red"
                                    },
                                    label: {
                                        show: true,
                                        color: 'white'
                                    }

                                }
                            ]
                        }
                    };
                    option.series.push(obj);
                }

                myChart.setOption(option, true);
                myChart.resize();
            })
            .error(function (data, status, headers, config) {
            });

        times = setInterval(function () {
            $.ajax({
                type: "post",
                url: '../Dashboard/GetNowDataByMn',
                data: { "Config": Type, "MnList": mnlist },
                success: function (datas) {
                    if (datas.length > 0) {
                        option.xAxis[0].data.shift();
                        option.xAxis[0].data.push(datas[0].TimeStr);
                    }
                    for (var i = 0; i < datas.length; i++) {
                        var name = datas[i].Name;
                        for (var j = 0; j < option.series.length; j++) {
                            if (option.series[j].name == name) {
                                option.series[j].data.shift();
                                option.series[j].data.push(datas[i].Values);
                                if (datas[i].Values != null && datas[i].Values > maxvalue) {
                                    option.series[j].itemStyle.normal.lineStyle.color = "red";
                                    option.series[j].itemStyle.normal.color = "red";
                                }
                                else {
                                    option.series[j].itemStyle.normal.lineStyle.color = colorarrays[j];
                                    option.series[j].itemStyle.normal.color = colorarrays[j];
                                }
                            }
                        }
                    }
                    myChart.setOption(option);

                }, error: function (err) {

                }
            });
        }, 60000);
    }
    $scope.GetPortPressure = function () {
        var charobj = document.getElementById('chart_portexpressure');
        charobj.style.width = (document.getElementById('chart_portexpressure')).offsetWidth + "px";
        var myChart = echarts.init(charobj);
        var valuelist = [];
        var timelist = [];
        var namelist = [];
        var option = {};
        var colorarrays = ["#00FFFF", "#00FA9A", "#4169E1", "#006400", "#5F9EA0", "#4682B4", "white", "#357F88", "#673509", "#310937", "#1B9637", "#F7393C"];
        var minvalue = 0;
        var maxvalue = 0;
        var mnlist = ['env_realtime#100000000031011512150782'];
        $http({
            method: 'POST',
            url: '../Monitor/Get2014HistoryPortPressure'
        })
            .success(function (datas) {
                for (var i = 0; i < datas.length; i++) {
                    namelist.push(datas[i].name);
                    timelist = datas[i].xdata;
                }
                if (datas.length > 0) {
                    minvalue = datas[0].Min;
                    maxvalue = 0.8;//datas[0].Max;
                }
                option = {
                    grid: {
                        left: '10%',
                        right: '10%',
                        top: '15%',
                        bottom: '10%',
                    },
                    legend: {
                        data: namelist,
                        left: 'right',
                        top: 20,
                        textStyle: {
                            color: "#fff"
                        },
                    },
                    tooltip: {
                        trigger: 'axis'
                    },
                    xAxis: [
                        {
                            type: 'category',
                            boundaryGap: false,
                            data: timelist,
                            axisLine: {
                                show: true,
                                lineStyle: {
                                    color: "rgba(219,225,255,1)",
                                    width: 1,
                                    type: "solid"
                                }
                            },
                            splitLine: {
                                show: true,
                                lineStyle: {
                                    color: ['#2F4F4F'],
                                    width: 1,
                                    type: 'solid'
                                }
                            }


                        }
                    ],
                    yAxis: [
                        {
                            min: minvalue,
                            // min 是最小的值
                            max: 1,
                            splitLine: {
                                show: true,
                                lineStyle: {
                                    color: ['#2F4F4F'],
                                    width: 1,
                                    type: 'solid'
                                }
                            },
                            type: 'value',
                            name: 'Mpa',
                            axisLine: {
                                show: true,
                                lineStyle: {
                                    color: "rgba(219,225,255,1)",
                                    width: 1,
                                    type: "solid"
                                }
                            }
                        }
                    ],
                    series: []
                };
                option.series = [];

                for (var i = 0; i < namelist.length; i++) {
                    var obj = {
                        name: namelist[i],
                        data: datas[i].ydata,
                        type: 'line',
                        smooth: true,
                        itemStyle: {
                            normal: {
                                color: colorarrays[i],
                                lineStyle: {
                                    color: colorarrays[i],
                                }
                            }
                        },
                        markLine: {
                            silent: true,
                            symbol: "none",
                            lineStyle: {
                                color: '#333'
                            },
                            data: [

                                {
                                    yAxis: 0.6,
                                    lineStyle: {               //警戒线的样式  ，虚实  颜色
                                        type: "dashed",
                                        color: "red"
                                    },
                                    label: {
                                        show: true,
                                        color: 'white'
                                    }

                                }
                            ]
                        }
                    };
                    option.series.push(obj);
                }

                myChart.setOption(option, true);
                myChart.resize();
            })
            .error(function (data, status, headers, config) {
            });

        times = setInterval(function () {
            $.ajax({
                type: "post",
                url: '../Monitor/Get2014PortPressure',
                success: function (datas) {
                    if (datas.length > 0) {
                        if (option.xAxis[0].data.length > 5) {
                            option.xAxis[0].data.shift();
                        }
                        option.xAxis[0].data.push(datas[0].xdata);
                    }
                    for (var i = 0; i < datas.length; i++) {
                        var name = datas[i].name;
                        for (var j = 0; j < option.series.length; j++) {
                            if (option.series[j].name == name) {
                                if (option.series[j].data.length > 5) {
                                    option.series[j].data.shift();
                                }
                                option.series[j].data.push(datas[i].ydata);
                                if (datas[i].Values != null && datas[i].Values > maxvalue) {
                                    option.series[j].itemStyle.normal.lineStyle.color = "red";
                                    option.series[j].itemStyle.normal.color = "red";
                                }
                                else {
                                    option.series[j].itemStyle.normal.lineStyle.color = colorarrays[j];
                                    option.series[j].itemStyle.normal.color = colorarrays[j];
                                }
                            }
                        }
                    }
                    myChart.setOption(option);

                }, error: function (err) {

                }
            });
        }, 30000);
    }
    $scope.GL2014Status = function () {
        $scope.GList = [];
        var namelist = ["20014锅炉房-立式锅炉1", "20014锅炉房-立式锅炉2", "20014锅炉房-立式锅炉3", "20014锅炉房-立式锅炉4", "20014锅炉房-立式锅炉5"];
        $http({
            method: 'POST',
            url: '../Emergency/GetDangerDeviceRunStatus',
            data: { 'namelist': namelist }
        })
            .success(function (ret) {
                $scope.GList = ret;

            })
            .error(function (data, status, headers, config) {

            });
        times = setInterval(function () {
            $http({
                method: 'POST',
                url: '../Emergency/GetDangerDeviceRunStatus',
                data: { 'namelist': namelist }
            })
                .success(function (ret) {
                    $scope.GList = ret;

                })
                .error(function (data, status, headers, config) {

                });
        }, 60000);
    }

    $scope.WasteWater = function () {
        $scope.WaterList = [];
        $http({
            method: 'POST',
            url: '../Emergency/GetWasteWaterNowData',
            data: { 'FactoryAreaId': 0 }
        })
            .success(function (ret) {
                $scope.WaterList = ret;
                setTimeout(function () {
                    $("#slider").easySlider({
                        slideSpeed: 500, autoSlide: true,
                        paginationSpacing: "15px",
                        paginationDiameter: "12px",
                        paginationPositionFromBottom: "2px",
                        slidesClass: ".slides",
                        controlsClass: ".controls",
                        paginationClass: ".pagination"
                    });
                }, 2000)

            })
            .error(function (data, status, headers, config) {

            });
        times = setInterval(function () {
            $http({
                method: 'POST',
                url: '../Emergency/GetWasteWaterNowData',
                data: { 'FactoryAreaId': 0 }
            })
                .success(function (ret) {
                    $scope.WaterList = ret;
                    setTimeout(function () {
                        $("#slider").easySlider({
                            slideSpeed: 500,
                            autoSlide: true,
                            paginationSpacing: "15px",
                            paginationDiameter: "12px",
                            paginationPositionFromBottom: "2px",
                            slidesClass: ".slides",
                            controlsClass: ".controls",
                            paginationClass: ".pagination"
                        });
                    }, 2000)
                })
                .error(function (data, status, headers, config) {

                });
        }, 60000);
    }

    $scope.InitDangerWasteBarCharts = function () {
        $http({
            method: 'POST',
            url: '../DangerWaste/GetAllDangerWasteList'
        })
            .success(function (ret) {
                $scope.ChartList = ret.Data;
                var names = new Array();
                var valus = new Array();
                for (var i = 0; i < $scope.ChartList.length; i++) {
                    if ($scope.ChartList[i].NowWeight > 0) {
                        names.push($scope.ChartList[i].WasteName.substring(0, 5));
                        valus.push($scope.ChartList[i].NowWeight);
                    }
                }
                var charobj = document.getElementById('chart_dangerwaste');
                charobj.style.width = document.getElementById("chart_dangerwaste").offsetWidth + "px";

                var myChart = echarts.init(charobj);

                // 使用刚指定的配置项和数据显示图表。

                var option = {
                    tooltip: {
                        trigger: 'axis',
                        axisPointer: {            // 坐标轴指示器，坐标轴触发有效
                            type: 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
                        }
                    },
                    grid: {
                        left: '3%',
                        right: '4%',
                        bottom: '3%',
                        containLabel: true
                    },
                    xAxis: [
                        {
                            type: 'category',
                            data: names,
                            axisTick: {
                                alignWithLabel: true
                            },
                            axisLabel: {
                                textStyle: {
                                    color: 'white'
                                }
                            }
                        }
                    ],
                    yAxis: [
                        {
                            type: 'value',
                            splitLine: false,
                            axisLabel: {
                                textStyle: {
                                    color: 'white'
                                }
                            }
                        }
                        
                    ],
                    series: [
                        {
                            name: '现存量',
                            type: 'bar',
                            barWidth: '60%',
                            data: valus
                        }
                    ]
                };

                myChart.setOption(option);
                myChart.resize();
            })
            .error(function (data, status, headers, config) {
                common.error($scope);
            });
    }

    $scope.DangerWaste = function () {
        var myChart = echarts.init(document.getElementById('chart_dangerwaste'));
        var namelist = [];
        option = {
            tooltip: {
                trigger: 'item',
                formatter: "{a} <br/>{b} : {c}吨"
            },
            legend: {
                show: false,
                x: 'center',
                y: '15%',
                icon: 'circle',
                textStyle: {
                    color: '#fff',
                }
            },
            calculable: true,
            series: [{
                name: '',
                type: 'pie',
                //起始角度，支持范围[0, 360]
                startAngle: 0,
                //饼图的半径，数组的第一项是内半径，第二项是外半径
                radius: [35, 90.75],
                //支持设置成百分比，设置成百分比时第一项是相对于容器宽度，第二项是相对于容器高度
                center: ['50%', '60%'],
                //是否展示成南丁格尔图，通过半径区分数据大小。可选择两种模式：
                // 'radius' 面积展现数据的百分比，半径展现数据的大小。
                //  'area' 所有扇区面积相同，仅通过半径展现数据大小
                roseType: 'area',
                //是否启用防止标签重叠策略，默认开启，圆环图这个例子中需要强制所有标签放在中心位置，可以将该值设为 false。
                avoidLabelOverlap: false,
                label: {
                    normal: {
                        show: true,
                        formatter: "{a} {b} : {c}吨",
                        textStyle: {
                            color: 'white'
                        }
                    },
                    emphasis: {
                        show: true
                    }

                },
                labelLine: {
                    normal: {
                        show: true,
                        length2: 1,
                    },
                    emphasis: {
                        show: true
                    }
                },
                data: []
            }]
        };
        var lineData = [];
        var barData = [];

        $http({
            method: 'POST',
            url: '../DangerWaste/GetAllDangerWasteList',
        })
            .success(function (ret) {
                var datalist = ret.Data;
                var chartdata = [];
                for (var i = 0; i < datalist.length; i++) {
                    var obj = {
                        value: datalist[i].NowWeight,
                        name: datalist[i].WasteName
                    };
                    if (obj.value > 0) {
                        namelist.push(datalist[i].WasteName);
                        lineData.push(datalist[i].NowWeight + (datalist[i].NowWeight / 50));
                        barData.push(datalist[i].NowWeight);
                        chartdata.push(obj);
                    }



                }
                //        var option = {

                //            tooltip: {
                //                trigger: 'axis',
                //                axisPointer: {
                //                    type: 'shadow'
                //                }
                //            },
                //            legend: {
                //                data: namelist,
                //                textStyle: {
                //                    color: '#ccc'
                //                }
                //            },
                //            xAxis: {
                //                data: namelist,
                //                axisLine: {
                //                    lineStyle: {
                //                        color: '#ccc'
                //                    }
                //                }
                //            },
                //            yAxis: {
                //                splitLine: { show: false },
                //                axisLine: {
                //                    lineStyle: {
                //                        color: '#ccc'
                //                    }
                //                }
                //            },
                //            series: [{
                //                name: 'line',
                //                type: 'line',
                //                smooth: false,
                //                showAllSymbol: true,
                //                symbol: 'emptyCircle',
                //                symbolSize: 15,
                //                data: lineData
                //            }, {
                //                name: 'bar',
                //                type: 'bar',
                //                barWidth: 10,
                //                itemStyle: {
                //                    barBorderRadius: 5,
                //                    color: new echarts.graphic.LinearGradient(
                //                        0, 0, 0, 1,
                //                        [
                //                            { offset: 0, color: '#14c8d4' },
                //                            { offset: 1, color: '#43eec6' }
                //                        ]
                //                    )
                //                },
                //                data: barData
                //            }, {
                //                name: 'line',
                //                type: 'bar',
                //                barGap: '-100%',
                //                barWidth: 10,
                //                itemStyle: {
                //                    color: new echarts.graphic.LinearGradient(
                //                        0, 0, 0, 1,
                //                        [
                //                            { offset: 0, color: 'rgba(20,200,212,0.5)' },
                //                            { offset: 0.2, color: 'rgba(20,200,212,0.2)' },
                //                            { offset: 1, color: 'rgba(20,200,212,0)' }
                //                        ]
                //                    )
                //                },
                //                z: -12,
                //                data: lineData
                //            }, {
                //                name: 'dotted',
                //                type: 'pictorialBar',
                //                symbol: 'rect',
                //                itemStyle: {
                //                    color: '#0f375f'
                //                },
                //                symbolRepeat: true,
                //                symbolSize: [12, 4],
                //                symbolMargin: 1,
                //                z: -10,
                //                data: lineData
                //            }]
                //        };
                option.legend.data = namelist;
                option.series[0].data = chartdata;
                myChart.setOption(option);
                window.addEventListener("resize", function () {
                    myChart.resize();
                });
            })
            .error(function (data, status, headers, config) {

            });
    }

    $scope.InitConstructionPie = function () {
        var myChart = echarts.init(document.getElementById('ConstructionPieChart'), 'shine');
        var option = {
            title: {
                show: false,
                text: "",
                subtext: '',
                left: 'center',
                textStyle: {
                    color: "white"
                }
            },
            tooltip: {
                trigger: 'item',
                formatter: '{b}: {c} 次'
            },
            grid: {
                left: '10%',
                right: '10%',
                top: '10%',
                bottom: '10%',
            },
            legend: {
                left: 20,
                top: 20,
                textStyle: {
                    fontSize: 13,
                    color: 'rgba(255,255,255,.7)'
                }
            },
            series: [
                {
                    name: '',
                    type: 'pie',
                    radius: ['30%', '50%'],
                    center: ['50%', '50%'],
                    avoidLabelOverlap: true,
                    label: {
                        show: true,
                        position: 'bottom'
                    },
                    emphasis: {
                        label: {
                            show: true,
                            fontSize: '30',
                            fontWeight: 'bold'
                        }
                    },
                    labelLine: {
                        show: false
                    },
                    itemStyle: {
                        emphasis: {
                            shadowBlur: 10,
                            shadowOffsetX: 0,
                            shadowColor: 'rgba(0, 0, 0, 0.5)'
                        },
                        normal: {
                            color: function (params) {
                                //自定义颜色
                                var colorList = [
                                    '#00FF00', '#00FFFF', '#FFFF00', '#FF8C00', '#FF0000', '#FE8463',
                                ];
                                return colorList[params.dataIndex]
                            }
                        }
                    }
                }
            ]
        };
        $http({
            method: 'POST',
            url: '../Emergency/GetConstructionPieData',
        })
            .success(function (ret) {
                var ChartList = ret;
                var dataArray = [];
                var nameArray = [];
                for (var i = 0; i < ChartList.length; i++) {
                    var datas = {};
                    datas.name = ChartList[i].name;
                    datas.value = ChartList[i].value;
                    nameArray.push(ChartList[i].name);
                    dataArray.push(datas);
                }
                option.series[0].data = dataArray;
                option.legend.data = nameArray;
                myChart.setOption(option);
                myChart.resize();
            })
            .error(function (data, status, headers, config) {

            });

        setInterval(function () {
            $http({
                method: 'POST',
                url: '../Emergency/GetConstructionPieData',
            })
                .success(function (ret) {
                    var ChartList = ret;
                    var dataArray = [];
                    var nameArray = [];
                    for (var i = 0; i < ChartList.length; i++) {
                        var datas = {};
                        datas.name = ChartList[i].name;
                        datas.value = ChartList[i].value;
                        nameArray.push(ChartList[i].name);
                        dataArray.push(datas);
                    }
                    option.series[0].data = dataArray;
                    option.legend.data = nameArray;
                    myChart.setOption(option);
                    myChart.resize();

                })
                .error(function (data, status, headers, config) {
                });
        }, 120000);
    }


    $scope.InitConstructionMonthTimes = function () {
        var myChart = echarts.init(document.getElementById('ConstructionMonthReport'), 'shine');
        var option = {
            title: {
                show: false,
                text: "月施工次数",
                textStyle: {
                    color: "white"
                },
                x: "center"
            },
            tooltip: {
                trigger: 'item',
                formatter: function (params) {
                    var res = params.name + '月施工次数：' + params.data + "次";
                    return res;
                }
            },
            grid: {
                top: '15%',
                left: '5%',
                width: '90%',
                height: '70%',
                containLabel: true
            },
            xAxis: {
                data: [],

                axisLabel: {
                    show: true,
                    interval: 0,
                    rotate: 40,
                    textStyle: {
                        fontSize: 15,
                        color: "white"
                    }
                },
                axisLine: {
                    lineStyle: {
                        color: '#fff',
                        width: 1,
                    }
                }
            },

            yAxis: {
                axisLabel: {
                    show: true,
                    textStyle: {
                        fontSize: 18,
                        color: '#fff',
                    }
                },
                axisLine: {
                    lineStyle: {
                        color: '#fff',
                        width: 1,
                    }
                },
                splitLine: {
                    show: false,
                }
            },

            series: {
                name: '',
                type: 'bar',
                barWidth: 18,
                data: [],
                itemStyle: {
                    normal: {
                        barBorderRadius: [5, 5, 5, 5],
                        color: new echarts.graphic.LinearGradient(
                            0, 0, 0, 1,
                            [
                                { offset: 0, color: '#3876cd' },
                                { offset: 0.5, color: '#45b4e7' },
                                { offset: 1, color: '#54ffff' }
                            ]
                        ),
                    },
                },
            },
        }
        $http({
            method: 'POST',
            url: '../Emergency/GetConstructionMonthTimes',
        })
            .success(function (ret) {
                var ChartList = ret;
                var dataArray = [];
                var nameArray = [];
                for (var i = 0; i < ChartList.length; i++) {
                    nameArray.push(ChartList[i].name);
                    dataArray.push(ChartList[i].value);
                }
                option.xAxis.data = nameArray;
                option.series.data = dataArray;
                myChart.setOption(option);
                myChart.resize();
            })
            .error(function (data, status, headers, config) {

            });
    }

    $scope.doRefshFactory = function () {
        $scope.FactoryAreaId = 2;

        $interval(function () {
            if ($scope.FactoryAreaId == 2) {
                $scope.FactoryAreaId = 1
            } else {
                $scope.FactoryAreaId = 2;
            }
        }, 10000);
    };

    $scope.GetJobHazardLocation = function (FactoryAreaId) {
        $scope.JobHazardLocation = [];
        $http({
            method: 'POST',
            url: '../Emergency/GetJobHazardLocation',
            data: { 'FactoryAreaId': FactoryAreaId }
        })
            .success(function (ret) {
                $scope.JobHazardLocation = ret;
            })
            .error(function (data, status, headers, config) {
            });
    }

    $scope.GetChemicalLocation = function (FactoryAreaId) {
        $scope.ChemicalLocation = [];
        $http({
            method: 'POST',
            url: '../Emergency/GetChemicalLocation',
            data: { 'FactoryAreaId': FactoryAreaId }
        })
            .success(function (ret) {
                $scope.ChemicalLocation = ret;
            })
            .error(function (data, status, headers, config) {
            });
    }

    $scope.GetDangerPlaceLocation = function (FactoryAreaId) {
        $scope.DangerPlaceList = [];
        $http({
            method: 'POST',
            url: '../Emergency/GetDangerPlaceList',
            data: { 'FactoryAreaId': FactoryAreaId }
        })
            .success(function (ret) {
                $scope.DangerPlaceList = ret;
            })
            .error(function (data, status, headers, config) {
            });
    }

    $scope.GetSpecialDevice = function () {
        $scope.SpecicalDeviceList = [];
        $http({
            method: 'POST',
            url: '../Emergency/GetTotalSpecicalDeviceList'
        })
            .success(function (ret) {
                $scope.SpecicalDeviceList = ret.Data;
            })
            .error(function (data, status, headers, config) {
            });
    }

    $scope.GetFireControlLocation = function (FactoryAreaId) {
        $scope.FireControlLocation = [];
        $http({
            method: 'POST',
            url: '../Emergency/GetFireControlLocation',
            data: { 'FactoryAreaId': FactoryAreaId }
        })
            .success(function (ret) {
                $scope.FireControlLocation = ret;
            })
            .error(function (data, status, headers, config) {
            });
    }

    $scope.GetLocationNowData = function () {
        $scope.LocationNowData = [];
        $http({
            method: 'POST',
            url: '../Emergency/GetLocationNowData'
        })
            .success(function (ret) {
                $scope.LocationNowData = ret;
            })
            .error(function (data, status, headers, config) {
            });

        setInterval(function () {
            $http({
                method: 'POST',
                url: '../Emergency/GetLocationNowData'
            })
                .success(function (ret) {
                    $scope.LocationNowData = ret;

                })
                .error(function (data, status, headers, config) {
                });
        }, 60000);
    }

    $scope.GetWaterLevelNowData = function () {
        $scope.LocationNowData = [];
        $http({
            method: 'POST',
            url: '../Emergency/GetWaterLevel'
        })
            .success(function (ret) {
                $scope.WaterLevelData = ret;
            })
            .error(function (data, status, headers, config) {
            });

        setInterval(function () {
            $http({
                method: 'POST',
                url: '../Emergency/GetWaterLevel'
            })
                .success(function (ret) {
                    $scope.WaterLevelData = ret;

                })
                .error(function (data, status, headers, config) {
                });
        }, 60000);
    }

    $scope.GetAlarmLocation = function () {
        $scope.AlarmLocation = [];
        $http({
            method: 'POST',
            url: '../Emergency/GetAlarmLocation'
        })
            .success(function (ret) {
                $scope.AlarmLocation = ret.Data;
            })
            .error(function (data, status, headers, config) {
            });

        setInterval(function () {
            $http({
                method: 'POST',
                url: '../Emergency/GetAlarmLocation'
            })
                .success(function (ret) {
                    $scope.AlarmLocation = ret.Data;

                })
                .error(function (data, status, headers, config) {
                });
        }, 60000);
    }

    $scope.GetHiddenTroubleList = function (FactoryAreaId) {
        $scope.HiddenTroubleLocation = [];
        $http({
            method: 'POST',
            url: '../Emergency/GetHiddenTroubleList',
            data: { 'FactoryAreaId': FactoryAreaId }
        })
            .success(function (ret) {
                $scope.HiddenTroubleLocation = ret;
            })
            .error(function (data, status, headers, config) {
            });
    }

    $scope.ShowFireControl = function () {
        $scope.IsFireControl = true;
        var control = document.getElementById("chk_firecontrol");
        if (control.checked) {
            $scope.IsFireControl = true;
        }
        else {
            $scope.IsFireControl = false;
        }
    }

    $scope.ShowChemical = function () {
        $scope.IsChemical = true;
        var control = document.getElementById("chk_chemical");
        if (control.checked) {
            $scope.IsChemical = true;
        }
        else {
            $scope.IsChemical = false;
        }
    }

    $scope.ShowJobHazard = function () {
        $scope.IsJobHazard = true;
        var control = document.getElementById("chk_jobhazard");
        if (control.checked) {
            $scope.IsJobHazard = true;
        }
        else {
            $scope.IsJobHazard = false;
        }
    }


    $scope.ShowDangerWork = function () {
        $scope.IsDangerWork = true;
        var control = document.getElementById("chk_dangerwork");
        if (control.checked) {
            $scope.IsDangerWork = true;
        }
        else {
            $scope.IsDangerWork = false;
        }
    }

    $scope.ShowWasteWaterExhaust = function () {
        $scope.IsShowPort = true;
        var control = document.getElementById("chk_wastewaterandexhaust");
        if (control.checked) {
            $scope.IsShowPort = true;
        }
        else {
            $scope.IsShowPort = false;
        }
    }

    $scope.ShowDangerPlace = function () {
        $scope.IsDangerPlace = true;
        var control = document.getElementById("chk_dangerplace");
        if (control.checked) {
            $scope.IsDangerPlace = true;
        }
        else {
            $scope.IsDangerPlace = false;
        }
    }

    $scope.ControlCenter = function (Type) {
        $scope.IsShowPort = false;
        $scope.IsDangerPlace = false;
        $scope.IsShowRisk = false;
        $scope.IsDangerWork = false;
        $scope.IsJobHazard = false;
        $scope.IsChemical = false;
        if (Type == "IsShowPort")
            $scope.IsShowPort = true;
        else if (Type == "IsDangerPlace")
            $scope.IsDangerPlace = true;
        else if (Type == "IsDangerWork")
            $scope.IsDangerWork = true;
        else if (Type == "IsJobHazard")
            $scope.IsJobHazard = true;
        else if (Type == "IsChemical")
            $scope.IsChemical = true;
        else if (Type == "IsShowRisk")
            $scope.IsShowRisk = true;
    }

    $scope.doMapMouse = function (type, index) {
        if ($scope.LastId != undefined) {
            var last = document.getElementById($scope.LastId);
            if (last != null) last.style = "display:none";
        }
        $scope.LastId = type + index;
        var id = type + index;
        var detail = document.getElementById(id);
        detail.style = "display:inline";
    }

    $scope.MouseLeave = function (type, index) {
        var id = type + index;
        var detail = document.getElementById(id);
        if (detail != null) {
            detail.style = "display:none";
        }
    }


    $scope.ShowPhotos = function (id, imageUrls) {
        var pswpElement = document.querySelectorAll('.pswp')[0];
        var items = [];
        for (var index in imageUrls) {
            var imgurl = imageUrls[index];
            var imgs = new Image();
            imgs.src = imgurl;
            var wi = imgs.width,
                hi = imgs.height;
            var item = {
                src: imgurl,
                w: wi,
                h: hi
            };
            items.push(item);
        }
        var options = {
            optionName: 'option value',
            // for example:
            index: id // start at first slide
        };
        // Initializes and opens PhotoSwipe
        var gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, options);
        gallery.init();
    }

    $scope.GetLocation = function (FactoryAreaId) {
        $scope.LocationList = [];
        $http({
            method: 'POST',
            url: '../DashBoard/GetLocation',
            data: { 'FactoryAreaId': FactoryAreaId }
        })
            .success(function (ret) {
                $scope.LocationList = ret;
            })
            .error(function (data, status, headers, config) {
            });
    }

    $scope.GetRiskList = function (FactoryAreaId) {
        $scope.LocationList = [];
        $http({
            method: 'POST',
            url: '../Emergency/GetRiskList',
            data: { 'FactoryAreaId': 0 }
        })
            .success(function (ret) {
                $scope.RiskList = ret.Data;
            })
            .error(function (data, status, headers, config) {
            });
    }

    $scope.GetConstructionWork = function () {
        $scope.ConstructionWorkList = [];
        $http({
            method: 'POST',
            url: '../Emergency/GetDangerWorkList',
        })
            .success(function (ret) {
                $scope.ConstructionWorkList = ret;
            })
            .error(function (data, status, headers, config) {
            });
    }
    $scope.GetConstructionWorkLocation = function () {
        $scope.DangerWorkList = [];
        $http({
            method: 'POST',
            url: '../Emergency/GetDangerWorkList',
        })
            .success(function (ret) {
                $scope.DangerWorkList = ret;
            })
            .error(function (data, status, headers, config) {
            });
    }
    $scope.GetConstructionWorkList = function (start, end) {
        $scope.ConstructionWorkList = [];
        $scope.ConstructionWork = {};
        $http({
            method: 'POST',
            url: '../Emergency/GetDangerWorkList',
            data: { 'start': start, 'end': end }
        })
            .success(function (ret) {
                $scope.ConstructionWorkList = ret;
                if ($scope.ConstructionWorkList.length > 0) {
                    $scope.ConstructionWork = $scope.ConstructionWorkList[0];
                }
                else {
                    $http({
                        method: 'POST',
                        url: '../Emergency/GetLastDangerWorkList',
                    })
                        .success(function (ret) {
                            $scope.ConstructionWork = ret;
                        })
                        .error(function (data, status, headers, config) {
                        });
                }
            })
            .error(function (data, status, headers, config) {
            });
        setInterval(function () {
            $scope.ConstructionWorkList = [];
            $scope.ConstructionWork = {};
            $http({
                method: 'POST',
                url: '../Emergency/GetDangerWorkList',
                data: { 'start': start, 'end': end }
            })
                .success(function (ret) {
                    $scope.ConstructionWorkList = ret;
                    if ($scope.ConstructionWorkList.length > 0) {
                        $scope.ConstructionWork = $scope.ConstructionWorkList[0];
                    }
                    else {
                        $http({
                            method: 'POST',
                            url: '../Emergency/GetLastDangerWorkList',
                        })
                            .success(function (ret) {
                                $scope.ConstructionWork = ret;
                            })
                            .error(function (data, status, headers, config) {
                            });
                    }
                })
                .error(function (data, status, headers, config) {
                });
        }, 120000);
    }

    $scope.ChangeFactory = function (model) {
        if (model.FactoryAreaId == 1) {
            model.FactoryAreaId = 2;
        }
        else {
            model.FactoryAreaId = 1;
        }
        $scope.GetLocation(model.FactoryAreaId);
        $scope.GetDangerPlaceLocation(model.FactoryAreaId);
    }

    $scope.ChangeFactoryByArea = function (model, Id) {
        model.FactoryAreaId = Id;
        $scope.GetLocation(Id);
        $scope.GetDangerPlaceLocation(Id);
        $scope.GetRiskList(Id);
    }

    $scope.GetAlarmDetail = function (Id) {
        $scope.AlarmDetail = {};
        $http({
            method: 'POST',
            url: '../Emergency/GetAlarmDetail',
            data: { 'Id': Id }
        })
            .success(function (ret) {
                $scope.AlarmDetail = ret.Data;
                $scope.doMapMouse('Alarm', $scope.AlarmDetail.Env_MnNo);
                $scope.model.FactoryAreaId = $scope.AlarmDetail.FactoryAreaId;
            })
            .error(function (data, status, headers, config) {
            });

    }

    $scope.GetEmergencyModule = function () {
        $scope.FireControlLocation = [];
        $http({
            method: 'POST',
            url: '../Emergency/GetEmergencyModuleList',
        })
            .success(function (ret) {
                $scope.ModuleList = ret;
            })
            .error(function (data, status, headers, config) {
            });
    }

    $scope.GetEPI = function () {
        $scope.EPIScore = [];
        $http({
            method: 'POST',
            url: '../DashBoard/GetEPI',
        })
            .success(function (ret) {
                $scope.EPIScore = ret.value.toFixed(2);
            })
            .error(function (data, status, headers, config) {
            });
        setInterval(function () {
            $http({
                method: 'POST',
                url: '../DashBoard/GetEPI',
            })
                .success(function (ret) {
                    $scope.EPIScore = ret.value.toFixed(2);
                })
                .error(function (data, status, headers, config) {
                });
        }, 120000);
    }
    $scope.GetWaterWPI = function () {
        $scope.EPIScore = [];
        $http({
            method: 'POST',
            url: '../DashBoard/GetWasteWaterAPI',
        })
            .success(function (ret) {
                $scope.WPIScore = ret.toFixed(2);
            })
            .error(function (data, status, headers, config) {
            });
        setInterval(function () {
            $http({
                method: 'POST',
                url: '../DashBoard/GetWasteWaterAPI',
            })
                .success(function (ret) {
                    $scope.WPIScore = ret.toFixed(2);
                })
                .error(function (data, status, headers, config) {
                });
        }, 120000);
    }
    $scope.GetExhaustAPI = function () {
        $scope.EPIScore = [];
        $http({
            method: 'POST',
            url: '../DashBoard/GetExhaustAPI',
        })
            .success(function (ret) {
                $scope.APIScore = ret.toFixed(2);
            })
            .error(function (data, status, headers, config) {
            });
        setInterval(function () {
            $http({
                method: 'POST',
                url: '../DashBoard/GetExhaustAPI',
            })
                .success(function (ret) {
                    $scope.APIScore = ret.toFixed(2);
                })
                .error(function (data, status, headers, config) {
                });
        }, 120000);
    }
    $scope.ShowAppList = function (applist) {
        $('.filterbg').show();
        $('.carInfo').show();
        $('.carInfo').width('3px');
        $('.carInfo').animate({ height: '50%' }, 400, function () {
            $('.carInfo').animate({ width: '22%' }, 400);
        });
        setTimeout(function () {
            $('.infoBox').show();
            $('.carClose').css('display', 'block');
        }, 800);
        $scope.AppList = applist;
    }

    $scope.GetAlarmList = function () {
        $scope.UnConfirmAlarmList = [];
        $http({
            method: 'POST',
            url: '../Emergency/GetAlarmList',
            data: { 'count': 50, 'type': 0 }
        })
            .success(function (ret) {
                $scope.UnConfirmAlarmList = ret.Data;
            })
            .error(function (data, status, headers, config) {
            });
        setInterval(function () {
            $http({
                method: 'POST',
                url: '../Emergency/GetAlarmList',
                data: { 'count': 50, 'type': 0 }
            })
                .success(function (ret) {
                    $scope.UnConfirmAlarmList = ret.Data;
                })
                .error(function (data, status, headers, config) {
                });
        }, 120000);
    }


    $scope.GetConfirmAlarmList = function () {
        $scope.ConfirmAlarmList = [];
        $http({
            method: 'POST',
            url: '../Emergency/GetAlarmList',
            data: { 'count': 50, 'type': 1 }
        })
            .success(function (ret) {
                $scope.ConfirmAlarmList = ret.Data;
            })
            .error(function (data, status, headers, config) {
            });
        setInterval(function () {
            $http({
                method: 'POST',
                url: '../Emergency/GetAlarmList',
                data: { 'count': 50, 'type': 1 }
            })
                .success(function (ret) {
                    $scope.ConfirmAlarmList = ret.Data;
                })
                .error(function (data, status, headers, config) {
                });
        }, 120000);
    }

    $scope.GetMessageReport = function (Id, event) {
        $scope.MessageReportList = [];
        var position = getCrossBrowserElement(event);
        $http({
            method: 'POST',
            url: '../Emergency/GetMessageReport',
            data: { 'uuid': Id }
        })
            .success(function (ret) {
                $scope.MessageReportList = ret;
                $("#MessageReport").css("display", "inline");
                $("#MessageReport").css("left", position.x + "px");
                $("#MessageReport").css("top", position.y + "px");

            })
            .error(function (data, status, headers, config) {
            });
    }
    $scope.HideMessage = function () {
        $("#MessageReport").css("display", "none");
    }

    function getCrossBrowserElement(mouseEvent) {
        var result = {
            x: 0,
            y: 0,
            relativeX: 0,
            relativeY: 0,
            currentDomId: ""
        };

        if (!mouseEvent) {
            mouseEvent = window.event;
        }

        if (mouseEvent.pageX || mouseEvent.pageY) {
            result.x = mouseEvent.pageX;
            result.y = mouseEvent.pageY;
        }
        else if (mouseEvent.clientX || mouseEvent.clientY) {
            result.x = mouseEvent.clientX + document.body.scrollLeft +
                document.documentElement.scrollLeft;
            result.y = mouseEvent.clientY + document.body.scrollTop +
                document.documentElement.scrollTop;
        }

        result.relativeX = result.x;
        result.relativeY = result.y;

        if (mouseEvent.target) {
            var offEl = mouseEvent.target;
            var offX = 0;
            var offY = 0;
            if (typeof (offEl.offsetParent) != "undefined") {
                while (offEl) {
                    offX += offEl.offsetLeft;
                    offY += offEl.offsetTop;
                    offEl = offEl.offsetParent;
                }
            }
            else {
                offX = offEl.x;
                offY = offEl.y;
            }

            result.relativeX -= offX;
            result.relativeY -= offY;
        }
        result.currentDomId = mouseEvent.target.id;

        return result;
    }

    $scope.GetAlarmChart = function () {
        var myChart = echarts.init(document.getElementById('chart_alarm'), 'shine');
        var option = {
            tooltip: {
                trigger: 'item',
                formatter: function (params) {
                    var res = params.name + '异常次数：' + params.data;
                    return res;
                }
            },
            grid: {
                top: '5%',
                left: '0%',
                width: '90%',
                height: '90%',
                containLabel: true
            },
            xAxis: {
                data: [],
                axisLabel: {
                    interval: 0,
                    show: true,
                    textStyle: {
                        fontSize: '12px',
                        color: '#fff',
                    },
                    rotate: -22
                },
                axisLine: {
                    lineStyle: {
                        color: '#fff',
                        width: 1,
                    }
                }

            },

            yAxis: {
                axisLabel: {
                    show: true,
                    textStyle: {
                        fontSize: '12px',
                        color: '#fff',
                    }
                },
                axisLine: {
                    lineStyle: {
                        color: '#fff',
                        width: 1,
                    }
                },
                splitLine: {
                    show: false,
                },
            },

            series: {
                name: '',
                type: 'line',
                data: [],
                itemStyle: {
                    normal: {
                        lineStyle: {
                            color: '#00FFFF'
                        }
                    }
                },

            },
        };
        $http({
            method: 'POST',
            url: '../Emergency/GetAlarmChart'
        })
            .success(function (ret) {
                var ChartList = ret.Data;
                var dataArray = [];
                var nameArray = [];
                for (var i = 0; i < ChartList.length; i++) {
                    nameArray.push(ChartList[i].Name);
                    dataArray.push(ChartList[i].CountNum);
                }
                option.series.data = dataArray;
                option.xAxis.data = nameArray;
                myChart.setOption(option);
                myChart.resize();
            })
            .error(function (data, status, headers, config) {

            });
    }

    $scope.GetAlarmChart2 = function () {
        var chartObj = document.getElementById('chart_alarm2');
        chartObj.style.width = (document.getElementById('chart_alarm')).offsetWidth + "px";
        var myChart = echarts.init(chartObj, 'shine');
        var option1 = {
            legend: {
                show: false,
                x: 'center',
                y: '15%',
                data: [],
                icon: 'circle',
                textStyle: {
                    color: 'white',
                }
            },
            tooltip: {
                trigger: 'item',
                formatter: ''
            },
            series: [
                {
                    name: '重点设备',
                    type: 'pie',
                    radius: ['40%', '70%'],
                    center: ['50%', '60%'],
                    avoidLabelOverlap: true,
                    label: {
                        show: true,
                        formatter: '{b}:{c}',
                        textStyle: {
                            color: 'white'
                        }
                    },
                    emphasis: {
                        label: {
                            show: false,
                            fontSize: '40',
                            fontWeight: 'bold'
                        }
                    },
                    labelLine: {
                        show: true
                    },
                    data: []
                }
            ]
        };
        $http({
            method: 'POST',
            url: '../Emergency/GetAlarmChartByEnv'
        })
            .success(function (ret) {
                var datalist = [];
                for (var i = 0; i < ret.length; i++) {
                    var obj = {};
                    obj.name = ret[i].Env_MnName;
                    obj.value = ret[i].Num;
                    datalist.push(obj);
                }
                option1.series[0].data = datalist;
                myChart.setOption(option1);
                myChart.resize();
            })
            .error(function (data, status, headers, config) {

            });
    }

    $scope.ConfirmAlarm = function (Id) {
        $http({
            method: 'POST',
            url: '../Emergency/ConfirmAlarm',
            data: { 'Id': Id }
        })
            .success(function (ret) {
                $scope.GetAlarmList();
                $scope.GetConfirmAlarmList();
            })
            .error(function (data, status, headers, config) {
            });
    }

    function randomData() {
        now = new Date(+now + oneDay);
        value = value + Math.random() * 21 - 10;
        return {
            name: now.toString(),
            value: [
                [now.getFullYear(), now.getMonth() + 1, now.getDate()].join('/'),
                Math.round(value)
            ]
        }
    }

    function get10MinutesScale() {
        var currDate = new Date();
        var odd = currDate.getMinutes() % 10;
        var returnArr = new Array();
        currDate.setMinutes(currDate.getMinutes() - odd);
        for (var i = 0; i < 7; i++) {
            returnArr.push(currDate.getHours() + ":" + (currDate.getMinutes() < 10 ? ("0" + currDate.getMinutes()) : currDate.getMinutes()));
            currDate.setMinutes(currDate.getMinutes() - 10);
        }
        return returnArr;
    }
    $scope.GetVoltage = function () {
        var myChart = echarts.init(document.getElementById('chart_v'), 'shine');
        var option = {
            title: {
                text: ''
            },
            tooltip: {
                trigger: 'axis'
            },
            legend: {
                top: 20,
                right: 5,
                textStyle: {
                    color: 'white'
                },
                orient: 'vertical',
                data: [
                    { name: '1#', icon: 'circle' },
                    { name: '2#', icon: 'circle' },
                    { name: '3#', icon: 'circle' }
                ]
            },
            grid: {
                left: '3%',
                right: '16%',
                bottom: '3%',
                top: '5%',
                containLabel: true
            },
            xAxis: {
                type: 'category',
                boundaryGap: false,
                axisTick: { show: false },
                axisLabel: {
                    textStyle: {
                        color: "white", //刻度颜色
                        fontSize: 18  //刻度大小
                    }
                },
                axisLine: {
                    show: true,
                    lineStyle: {
                        color: '#0B3148',
                        width: 1,
                        type: 'solid'
                    }
                },
                data: get10MinutesScale()
            },
            yAxis: {
                type: 'value',
                axisTick: { show: false },
                axisLabel: {
                    textStyle: {
                        color: "white", //刻度颜色
                        fontSize: 15  //刻度大小
                    }
                },
                axisLine: {
                    show: true,
                    lineStyle: {
                        color: '#0B3148',
                        width: 1,
                        type: 'solid'
                    }
                },
                splitLine: {
                    show: false
                }
            },
            series: [
                {
                    name: '1#',
                    type: 'line',
                    itemStyle: {
                        normal: {
                            color: '#F3891B'
                        },
                        lineStyle: {
                            normal: {
                                color: '#F3891B',
                                opacity: 1
                            }
                        }
                    },
                    data: [120, 132, 101, 134, 90, 230, 210]
                },
                {
                    name: '2#',
                    type: 'line',
                    itemStyle: {
                        normal: {
                            color: '#006AD4'
                        },
                        lineStyle: {
                            normal: {
                                color: '#F3891B',
                                opacity: 1
                            }
                        }
                    },
                    data: [220, 182, 191, 234, 290, 330, 310]
                },
                {
                    name: '3#',
                    type: 'line',
                    itemStyle: {
                        normal: {
                            color: '#009895'
                        },
                        lineStyle: {
                            normal: {
                                color: '#009895',
                                opacity: 1
                            }
                        }
                    },
                    data: [150, 232, 201, 154, 190, 330, 410]
                }
            ]
        };
        myChart.setOption(option);
    }

    $scope.GetElectricCurrent = function () {
        var myChart = echarts.init(document.getElementById('chart_A'), 'shine');
        var option = {
            title: {
                text: ''
            },
            tooltip: {
                trigger: 'axis'
            },
            legend: {
                top: 20,
                right: 5,
                textStyle: {
                    color: 'white'
                },
                orient: 'vertical',
                data: [
                    { name: '1#', icon: 'circle' },
                    { name: '2#', icon: 'circle' },
                    { name: '3#', icon: 'circle' }
                ]
            },
            grid: {
                left: '3%',
                right: '16%',
                bottom: '3%',
                top: '5%',
                containLabel: true
            },
            xAxis: {
                type: 'category',
                boundaryGap: false,
                axisTick: { show: false },
                axisLabel: {
                    textStyle: {
                        color: "white", //刻度颜色
                        fontSize: 18  //刻度大小
                    }
                },
                axisLine: {
                    show: true,
                    lineStyle: {
                        color: '#0B3148',
                        width: 1,
                        type: 'solid'
                    }
                },
                data: get10MinutesScale()
            },
            yAxis: {
                type: 'value',
                axisTick: { show: false },
                axisLabel: {
                    textStyle: {
                        color: "white", //刻度颜色
                        fontSize: 13  //刻度大小
                    }
                },
                axisLine: {
                    show: true,
                    lineStyle: {
                        color: '#0B3148',
                        width: 1,
                        type: 'solid'
                    }
                },
                splitLine: {
                    show: false
                }
            },
            series: [
                {
                    name: '1#',
                    type: 'line',
                    itemStyle: {
                        normal: {
                            color: '#F3891B'
                        },
                        lineStyle: {
                            normal: {
                                color: '#F3891B',
                                opacity: 1
                            }
                        }
                    },
                    data: [10, 20, 9, 16, 15, 2, 23]
                },
                {
                    name: '2#',
                    type: 'line',
                    itemStyle: {
                        normal: {
                            color: '#006AD4'
                        },
                        lineStyle: {
                            normal: {
                                color: '#F3891B',
                                opacity: 1
                            }
                        }
                    },
                    data: [9, 22, 11, 13, 14, 15, 6]
                },
                {
                    name: '3#',
                    type: 'line',
                    itemStyle: {
                        normal: {
                            color: '#009895'
                        },
                        lineStyle: {
                            normal: {
                                color: '#009895',
                                opacity: 1
                            }
                        }
                    },
                    data: [5, 3, 2, 4, 4, 11, 12]
                }
            ]
        };
        myChart.setOption(option);
    }


    $scope.ViewDetail = function (name, Id) {
        if (name == "2014锅炉房") {
            window.location.href = "../Emergency/DangerPlaceData";
        }

    }

    $scope.Show3D = function (name, Id) {
        if (Id == 46) {
            $('.filterbg').show();
            $('.carInfo').show();
            $('.carInfo').width('3px');
            $('.carInfo').animate({ height: '70%' }, 400, function () {
                $('.carInfo').animate({ width: '60%' }, 400);

            });
            setTimeout(function () {
                $('.infoBox').show();
                $('.carClose').css('display', 'block');
            }, 800);
            setTimeout(function () {
                $('.carInfo').css("overflow", "unset");
            }, 500);
        }

    }


    $scope.GetPower = function () {
        var myChart = echarts.init(document.getElementById('chart_P'), 'shine');
        var option = {
            title: {
                text: ''
            },
            tooltip: {
                trigger: 'axis'
            },
            legend: {
                top: 20,
                right: 5,
                textStyle: {
                    color: 'white'
                },
                orient: 'vertical',
                data: [
                    { name: '1#', icon: 'circle' },
                    { name: '2#', icon: 'circle' },
                    { name: '3#', icon: 'circle' }
                ]
            },
            grid: {
                left: '3%',
                right: '16%',
                bottom: '3%',
                top: '5%',
                containLabel: true
            },
            xAxis: {
                type: 'category',
                boundaryGap: false,
                axisTick: { show: false },
                axisLabel: {
                    textStyle: {
                        color: "white", //刻度颜色
                        fontSize: 18  //刻度大小
                    }
                },
                axisLine: {
                    show: true,
                    lineStyle: {
                        color: '#0B3148',
                        width: 1,
                        type: 'solid'
                    }
                },
                data: get10MinutesScale()
            },
            yAxis: {
                type: 'value',
                axisTick: { show: false },
                axisLabel: {
                    textStyle: {
                        color: "white", //刻度颜色
                        fontSize: 15  //刻度大小
                    }
                },
                axisLine: {
                    show: true,
                    lineStyle: {
                        color: '#0B3148',
                        width: 1,
                        type: 'solid'
                    }
                },
                splitLine: {
                    show: false
                }
            },
            series: [
                {
                    name: '1#',
                    type: 'line',
                    itemStyle: {
                        normal: {
                            color: '#F3891B'
                        },
                        lineStyle: {
                            normal: {
                                color: '#F3891B',
                                opacity: 1
                            }
                        }
                    },
                    data: [1000, 2000, 900, 1600, 1500, 200, 2300]
                },
                {
                    name: '2#',
                    type: 'line',
                    itemStyle: {
                        normal: {
                            color: '#006AD4'
                        },
                        lineStyle: {
                            normal: {
                                color: '#F3891B',
                                opacity: 1
                            }
                        }
                    },
                    data: [409, 252, 1110, 1300, 1411, 1552, 692]
                },
                {
                    name: '3#',
                    type: 'line',
                    itemStyle: {
                        normal: {
                            color: '#009895'
                        },
                        lineStyle: {
                            normal: {
                                color: '#009895',
                                opacity: 1
                            }
                        }
                    },
                    data: [500, 1300, 2000, 234, 524, 1111, 1222]
                }
            ]
        };
        myChart.setOption(option);
    }

});
app.filter("JSONDate", function ($filter) {
    return function (input, format) {
        if (input) {
            var r = input.replace(/[^0-9|-]+/g, '');
            var timestamp = Number(r);
            return $filter("date")(timestamp, format);
        }
        else {
            return input;
        }
    }
});
app.filter('GetAreaName', function () {
    return function (text) {
        if (text == 1) {
            return "浦东";
        }
        else if (text == 2) {
            return "大场";
        }
    }
});
app.filter('GetDangerLevel', function () {
    return function (status) {
        if (status == 1) {
            return "I";
        }
        else if (status == 2) {
            return "II";
        }
        else if (status == 3) {
            return "III";
        }
        else {
            return "";
        }
    }

});
app.filter('HideMobile', function () {
    return function (mobile) {
        var reg = /^(\d{3})\d{4}(\d{4})$/;
        mobile = mobile.replace(reg, "$1****$2");
        return mobile;
    }

});
app.filter('HideChar', function () {
    return function (text) {
        if (text.length > 4) {
            return text.substring(0, 3) + "...";
        }
        else {
            return text;
        }
    }

});

app.filter('SimpleName', function () {
    return function (text) {
        return text.replace('20014锅炉房-立式', '')
    }

});